package org.alanlau.demo;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.stereotype.Component;

/**
 * @author liukun
 * @version 1.0
 * @date 2019/12/25 17:41
 */
@Configuration
@EnableAsync
@Aspect
@Component
public class ThreadInfoAspect {
    private static final Logger logger = LoggerFactory.getLogger("threadInfo:");

    @Pointcut("execution(* org.alanlau.demo.TestService.test3(..))")
    public void pointCut() {
    }

    @Before("pointCut()")
    public void before() {
        System.out.println(Thread.currentThread().getName() + "开始执行");
    }

    @After("pointCut()")
    public void after() {
        System.out.println(Thread.currentThread().getName() + "执行结束");
    }
}
